Component({
  mixins: [],
  data: {
    name: "测试权益",
    startTime: '1611655553000',
    endTime: '1611914753000',
    appId: '3000000029413603',
    appUrl:'https://market.m.taobao.com/app/miniapp-biz/qrcode/index.html?_ariver_appid=3000000029413603',

    targetEntityList: ['626713308430'],

    myCallBack(res){console.info(res)},
    myCallBackWithSetData:null, // 使用进行setData的callback
    myBackCallback(){},
    myBackCallbackWithSetData:null,  // 注意this的指向(绑定this)

    stratTime:"2020-01-01 00:00:00",
    endTime:"2020-01-01 00:00:00"
  },
  props: {},
  didMount() {

    this.$page.pop = this 

    this.cb = this.cb.bind(this);
    this.backCb = this.backCb.bind(this);
    this.setData({
        myCallBackWithSetData: this.cb.bind(this),
        myBackCallbackWithSetData: this.backCb.bind(this),
    })

    // setTimeout(() => {
    //   this.setData({
    //     qrcode:this.$page.QRcode()
    //   })
    // }, 400);
    
    // console.log("564644654656565",this.$page.QRcode())

    // setTimeout(() => {
    //   if(getApp().JHZ == 'xx'){

    //     getApp().JHZ = '';

    //     let link=`https://m.duanqu.com?_ariver_appid=${getApp().APPID}`

    //      getApp().cloud.application.httpRequest({
    //         'path' : '/imageGenerator', 
    //         'method':'POST',
    //         'headers':{ "Content-Type":"application/json"},
    //         'body':{ content : link },
    //         }).then(res => {

    //           this.setData({
    //             qrcode:res.data
    //           })
    //           //return ress.data
    //           console.info("erweima",res.data)
    //       })

    //   }
    // }, 400);

   

    // console.log("jdhfjksjfksjfkl",this.data.qrcode)

    // 从活动列表页去到投放页二维码无效


    this.checkInfo();
    this.QRcode()
  

  },
  didUpdate() {},
  didUnmount() {},
  methods: {

    QRcode(){

      //my.alert({content:this.data.appId})

      let link=`https://m.duanqu.com?_ariver_appid=${getApp().APPID}`;

      getApp().cloud.application.httpRequest({
        'path' : '/imageGenerator', 
        'method':'POST',
        'headers':{ "Content-Type":"application/json"},
        'body':{ content : link },
        }).then(ress => {

          this.setData({
            qrcode:ress.data
          })

          console.info("erweima",ress.data);
          
      })


    },

   
    
    cb() {
      this.setData({ color: "setdata" })
    },

    backCb() {
      this.setData({ color: "setdata" })
    },


    checkInfo(){
      getApp().cloud.application.httpRequest({

        'path' : `/api/b/getActivityInfo/${getApp().activityId}`, 
        'method':'get',
        'headers':{ "Content-Type":"application/json"},
        'body':{},

        }).then(res => {


          if(res.code!=200){

            my.alert({content:res.msg})
            
          }else{

            this.setData({
              name:res.data.title,
              start:res.data.startTime,
              end:res.data.endTime
            })
            // if(this.lowOption){
            //   this.lowOption.onSubmit();
            // }

            // if(this.optionCpt){
            //   this.optionCpt.onSubmit();
            // }

            

            // this.setData({
            //   state:this.data.state + 1 > 3 ? 3 : this.data.state + 1
            // })
            console.info("保存活动配置信息",res)
          }
          

      })
    },

    

    tf(){
      // 拿到实例化后的小程序id
      //my.navigateTo({ url: 'plugin://myPlugin1/orightindex-page' });

      // let appid="3000000028703214";

      //https://market.m.taobao.com/app/taefed/shopping-delivery-wapp/index.html#/putin?mainKey=form&appId=3000000005074923


      // my.alert({content:getApp().APPID})

      let apppid = getApp().APPID

      //let apppid = "3000000029413603"
      
      let link = `https://market.m.taobao.com/app/taefed/shopping-delivery-wapp/index.html#/putin?mainKey=form&appId=${apppid}`;

       my.qn.navigateToWebPage({
        url: link,
        success: res => {
        },
        fail: res => {
        }
      })
      
    },

    dianputf(){
      my.qn.navigateToWebPage({
        url: "https://wangpu.taobao.com/wpFramework.htm#/wpdecorate/wpPageList/shop_index/index2/basic/1?tabId=0",
        success: res => {
        },
        fail: res => {
        }
      })
    },

    copyappurl(){
      my.setClipboard({
        text: `https://m.duanqu.com/?_ariver_appid=${getApp().APPID}`,
        success: res => {
          my.showToast({content:"复制成功！"});
        },
        fail: res => {
        }
      });
    },

    dpjc(){
      my.qn.navigateToWebPage({
        url: "https://www.yuque.com/docs/share/5ac8cd7d-b68f-4c15-a920-dd0befed2e4d",
        success: res => {
        },
        fail: res => {
        }
      })
    },

    zbjjc(){
      my.qn.navigateToWebPage({
        url: "https://www.yuque.com/docs/share/57e37b03-4994-44fd-851f-ef3e166e7b33",
        success: res => {
        },
        fail: res => {
        }
      })
    }


  },

  
});
